// v
0 xyz
1 xyz 
2 xyz
// n
0 xyz
1 xyz 
2 xyz
// texcoords

// material



struct Room
{
	vector< int > verts;
}

class Portal
{
	Vec3f *vertices;
	int numVertices;
}

// Game Programming
Portal intersect( Portal p1, Portal p2 )
{
	list<Vec3f> result;
	bool prevInside = false;
	
	if( p2.contains( p1.vertices[p1.numVertices-1] )
	{
		prevInside = true;
	}
	
	for(int i=0; i<p1.numVertices; i++)
	{
		curInside = p2.contains( p1.vertices[i] );
		if( curInside )
		{
			result.push_back( p1.vertices[i] );
			if( prevInside && !curInside ) || (!prevInside && curInside) )
			{
				int aux = i - 1;
				if( aux < 0 ) aux += p1.numVertices;
				
				Vec3f inter = compute_intersection( p2.vertices[aux], p1.vertices[i], p2 );
				result.push_back(inter);
			}
			prevInside = curInside;
		}
	}

	Portal presult(result); // copy this portal
	return presult;
}


// http://www.flipcode.com/archives/
// Harmless_Algorithms-Issue_02_Scene_Traversal_Algorithms.shtml#portalsrecursive
      void Node::visit(PortalSilhouette & silhouette) {
        if (last_seen != this_frame) {
          last_seen = this_frame;
          for each polygon do {
            if (s->is_a_portal) {
              Silhouette s = clip polygon using silhouette planes
              next if s is empty.
              s->remote_node->visit(s);
            } else { 
              Polygon p = clipped polygon using silhouette planes
              p->render();
            }
          }
        }
      }
 
// 
       for each node in the PVS for the viewpoint {
           node->render();
       }  


/////////